package edu.gatech.stolen.tea.unittest;
import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import edu.gatech.stolen.tea.*;

/**
 * A Junit test for all the methods in Accounts
 * @author Leshi
 *
 */
public class RegisterTest {
	private Accounts account;
	
	@Before
	public void setUp() {
	    account = new Accounts();
	}
	
	@Test
	public void testCreateUser(){
		account.createUser("a", "a");
		assertTrue("Account did not create user correctly", account.checkExistingUser("a"));
		assertFalse("Account did not check for duplicate username", account.createUser("a","b"));
		
		account.createUser("b", "b");
		assertTrue("Account did not create second user correctly", account.checkExistingUser("b"));
		
	}
	
	@Test
	public void testCheckExistingUser(){
		account.createUser("e","e");
		assertTrue("Account did not check existing user correctly", account.checkExistingUser("e"));
		assertFalse("Account did not check nonexisting user correctly", account.checkExistingUser("n"));

		
	}
	
	@Test
	public void testLogin(){
		account.createUser("a","a");
		assertTrue("Account did not login a existing user correctly",account.login("a", "a"));
		assertFalse("Account did not login a nonexisting user correctly",account.login("f", "f"));
		assertFalse("Account loggin in a user with wrong password",account.login("a", "b"));

	}
}
